<template>
	<view class="container" @click="goHistoryDetail">
		<view class="container__left">查看TA的历史记录</view>
		<view class="container__right" v-show="count">
			<view class="" style="margin-right: 10rpx;">本月已提交{{count}}次</view>
			<u-icon name="arrow-right" color="#aaa" size="13"></u-icon>
		</view>
	</view>
</template>

<script>
	import _custom from '@/common/_custom.js'
	
	export default {
		data() {
			return {
				count: 0
			}
		},
		props: {
			process: {
				type: Object,
				default: () => {}
			}
		},
		watch: {
			process: {
				deep: true,
				immediate: true,
				handler() {
					if(Object.keys(this.process).length) {
						this.$nextTick(function(){
							this.getUserHistoryFlowCount();
						})
						
					}
				}
			}
		},
		methods: {
			/**
			 * 获取用户历史相同流程发起次数
			 */
			getUserHistoryFlowCount() {
				let that = this;
				return new Promise((resolve,reject) => {
					_custom.getDataJava({
						apiname: 'getUserHistoryFlowCount',
						apiparam: {
							InsFlowId: this.process.InsFlowId,
						},
						success(res) {
							if(!res.length) return
							that.count = res[0].cnt;
						}
					})
				})
			},
			/**
			 * 跳转历史记录页面
			 */
			goHistoryDetail() {
				uni.navigateTo({
					url: '/pages/home/child/add-attend/history?count=' + this.count + '&insflowid=' + this.process.InsFlowId
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #fff;
		border-top: 1rpx solid #eee;
		height: 80rpx;
		padding: 0 20rpx;
		margin-bottom: 20rpx;
		
		&__left {
			font-size: 30rpx;
			padding-left: 10rpx;
		}
		
		&__right {
			font-size: 26rpx;
			color: #aaa;
			display: flex;
			align-items: center;
		}
	}
</style>
